package com.chis.jxc.utils;

import com.chis.jmdatatimer.comm.JedisSerializeUtil;
import org.apache.kafka.common.errors.SerializationException;
import org.apache.kafka.common.serialization.Deserializer;

import java.util.Map;

/**
 * @Description kafka序列化Class
 * @Company zwx
 * @author huangzh
 * @version 2018年6月28日
 */
public class DecodeingKafka implements Deserializer<Object> {

    @Override
    public void configure(Map<String, ?> map, boolean b) {

    }

    @Override
    public Object deserialize(String topic, byte[] bytes) {
        try {
            if (bytes == null)
                return null;
            else
                return JedisSerializeUtil.unserialize(bytes);
        }catch (Exception e){
            throw new SerializationException("Error when deserializing byte[] to Object.");
        }

    }

    @Override
    public void close() {

    }

    public DecodeingKafka() {
    }
}
